package com.ruoyi.framework.utils;

import net.dreamlu.mica.core.utils.WebUtil;
import org.springframework.context.annotation.Configuration;

import javax.servlet.http.HttpServletRequest;

/**
 * 服务相关配置
 *
 * @author ruoyi
 */
@Configuration
public class ServerUtils {

    /**
     * 获取完整的请求路径，包括：域名，端口，上下文访问路径
     *
     * @return 服务地址
     */
    public static String getServerDomain() {
        HttpServletRequest request = WebUtil.getRequest();
        String host = request.getServerName();
        int port = request.getServerPort();
        return "http://" + host + ":" + port;
    }
}
